Different techniques have been proposed for increasing cache locality for various workloads. One of the oldest and most basic algorithms is the least recently used (“LRU”) algorithm. The LRU algorithm evicts the page from the cache that was not accessed the longest. LRU is currently the policy of choice in many database systems due to its small overhead and tuning-free operation. Many variants of LRU have been proposed since. One example is LRU-K, as described in “The LRU-K page replacement algorithm for database disk buffering” E. J. O'Neil, P. E. O'Neil, and G. Weikum, In Proc. ACM SIGMOD Int. Conf. on Management of Data, pages 297-306, which is hereby incorporated by reference in its entirety. LRU-K evicts the page whose Kth most recent access is the longest in the past.
Another example, is 2Q as described in “2Q: A low overhead high performance buffer management replacement algorithm”, T. Johnson and D. Shasha, In Proc. Int. Conf. on Very Large Data Bases, pages 439-450, 1994, which is hereby incorporated by reference in its entirety. 2Q reduces LRU-K's logarithmic overhead to a constant overhead LFU is another example and is discussed in “Data cache management using frequency-based replacement”, J. Robinson and M. Devarakonda, In Proc. ACM SIGMETRICS Conf., pages 134-142, 1990, which is hereby incorporated by reference in its entirety. LFU evicts the page that was accessed least frequently. Hybrids have also been introduced such as LRFU, which combines LRU and LFU and ARC, which can adaptively switch between different eviction policies. LRU is further discussed in “LRFU: A spectrum of policies that subsumes the least recently used and least frequently used policies”, Lee, J. Choi, J.-H. Kim, S. H. Noh, S. L. Min, Y. Cho, and C. S. Kim. IEEE Trans. Computers, 50(12):1352-1360, 2001 and ARC is further discussed in “Outperforming LRU with an adaptive replacement cache”, N. Megiddo and D. Modha, 2004, which are bother hereby incorporated by reference in their entirety.
L. Belady in “A study of replacement algorithms for virtual storage computers”, IBM Systems Journal, 5(2):78-101, 1966, which is hereby incorporated by reference in its entirety, gives an optimal offline algorithm, MIN, for the cache replacement problem which evicts the page that is accessed the farthest in the future. All these techniques given above are for general access patterns. In other words, they are not directed towards sequential or ordered access patterns. Therefore, they do not provide an improved buffer utilization for this specific type of access.
Commercial database vendors such as Red Brick and Teradata employ proprietary algorithms to let the database synchronize multiple table scan operations in order to maximize buffer locality. See for example, “Red brick warehouse: a read-mostly RDBMS for open SMP platforms”, P. M. Fernandez, In Proc. ACM SIGMOD Int. Conf. on Management of Data, page 492, 1994; “Explaining cache—NCR CTO Todd Walter answers your trickiest questions on Teradata's caching functionality”, T. Walter, http://www.teradata.com/t/page/116344/; and, “TPC-D—The Challenges, Issues and Results”, R. Bhashyam, NCR Corporation, SIGMOD Record 25(4) 1996: 89-93, which are hereby incorporated by reference in their entireties.
This idea was taken even further in “A simultaneously pipelined relational query engine”, S. Harizopoulos, V. Shkapenyuk, and A. Ailamaki. QPipe, In Proc. ACM SIGMOD Int. Conf. on Management of Data, pages 383-394, 2005, which is hereby incorporated by reference in its entirety. Harizopoulos et al. proposes ideas for a new database architecture that tries to maximize reuse of partial query results from the query down to the page access level. This is achieved by detecting overlaps in active query plan operators at query execution time and then exploiting it by pipelining one operator's results to all dependent operators where possible. Two of the operators discussed in that paper are the table and index scan operators. For these, Harizopoulos et al. proposes to use one scan thread that keeps scanning all pages while table scan operators can attach to and detach from this thread in order to share the scanned pages. While this approach works well for scans with similar speeds, in practice scan speeds can vary by large margins and even single scans' speeds are usually far from constant due to changes in predicate evaluation overhead. Therefore, the benefit can be lower as scans may start drifting apart.
In addition to cache or page buffer algorithm improvements, other methods to reduce disk access costs for multiple concurrent queries with overlapping data accesses have been investigated. These methods include multi-query optimization that requires all queries to be known in advance. See for example, “Efficient and extensible algorithms for multi query optimization”, P. Roy, S. Seshadri, S. Sudarshan, and S. Bhobe, In Proc. ACM SIGMOD Int. Conf. on Management of Data, pages 249-260, 2000, which is hereby incorporated by reference in its entirety. These methods also include query result caching “Dynamic caching of query results for decision support systems”, J. Shim, P. Scheuermann, and R. Vingralek, In Proc. Int. Conf. on Scientific and Statistical Database Management, pages 254-263, 1999, which is hereby incorporated by reference in its entirety. Due to being at a high level of the query execution hierarchy, the latter may miss out on sharing potential for queries that have very different predicates but still end up performing table scans on the same table, for example.
“Cooperative Scans”, M. Zukowski, P. A. Boncz, M. L. Kersten, CWI Report 2004, INS-E0411, ISSN 1386-368, which is hereby incorporated by reference in its entirety introduces a smart buffer manager that is used to optimize page replacement under multiple running queries in order to maximize buffer locality. However, this approach requires significant modifications of the caching system. This invention, on the other hand, views the caching system as a “black box” and limits modifications to a few extra function calls in the scan code.
Therefore a need exists to overcome the problems with the prior art as discussed above.